using System.Xml.Linq;
using MathematicallySafe.HeadCounter.Data;
using MathematicallySafe.HeadCounter.Data.Interfaces;
using StructureMap;

namespace MathematicallySafe.HeadCounter.Services.Exporters
{
    public static class HtmlSnippetHelper
    {
        private static readonly IGuild Guild = ObjectFactory.GetInstance<IGuild>();

        public static XElement ContentContainer(XElement content)
        {
            return new XElement("div", new XAttribute("class", "Container"), content);
        }

        public static XElement ContentContainer(int span, XElement content)
        {
            return new XElement("div", new XAttribute("class", string.Format("span-{0} last", span)), content);
        }

        public static XElement CenteredContentContainer(int span, XElement content)
        {
            int prepend = ((24 - span) / 2);
            return new XElement("div",
                                new XAttribute("class", string.Format("prepend-{0} span-{1} last", prepend, span)),
                                content);
        }

        public static XElement MakeRaiderCell(string name)
        {
            var raider = Guild.FindRaider(name);
            var raiderClass = raider.Class.ToString();

            return new XElement("a",
                                new XAttribute("class", raiderClass),
                                new XAttribute("href", raider.WebSafeName + ".html"),
                                raider.Name
                );
        }
    }
}